classdef GRGUI_App_exported < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        figure1                         matlab.ui.Figure
        uitoolbar1                      matlab.ui.container.Toolbar
        uipanel                         matlab.ui.container.ButtonGroup
        btnLoadGravityData              matlab.ui.control.Button
        btnDZCEnvelopeFullScreen        matlab.ui.control.Button
        btnResultsResidualsFullScreen   matlab.ui.control.Button
        btnDZCResidualsFullScreen       matlab.ui.control.Button
        btnResultsGValuesFullScreen     matlab.ui.control.Button
        uipanel12                       matlab.ui.container.Panel
        text79                          matlab.ui.control.Label
        btnStartStop                    matlab.ui.control.StateButton
        editInstrumentStatus            matlab.ui.control.EditField
        uipanel11                       matlab.ui.container.Panel
        text82                          matlab.ui.control.Label
        editSetMeanSolidTidesCorrection  matlab.ui.control.EditField
        editSetmeanZCGValue             matlab.ui.control.EditField
        editSingleDropDropNumber        matlab.ui.control.EditField
        editStdDevMeanZCGValue          matlab.ui.control.EditField
        editStandardErrorMZCMeanGValue  matlab.ui.control.EditField
        editSingleDropCurrentGValue     matlab.ui.control.EditField
        text76                          matlab.ui.control.Label
        text75                          matlab.ui.control.Label
        text74                          matlab.ui.control.Label
        text73                          matlab.ui.control.Label
        text72                          matlab.ui.control.Label
        uipanel10                       matlab.ui.container.Panel
        editLatitude                    matlab.ui.control.EditField
        editGValueTolerance             matlab.ui.control.EditField
        text71                          matlab.ui.control.Label
        editExpectedGValue              matlab.ui.control.EditField
        editLongitude                   matlab.ui.control.EditField
        editHeight                      matlab.ui.control.EditField
        text70                          matlab.ui.control.Label
        editGravityGradient             matlab.ui.control.EditField
        editStation                     matlab.ui.control.EditField
        text69                          matlab.ui.control.Label
        text68                          matlab.ui.control.Label
        text67                          matlab.ui.control.Label
        text66                          matlab.ui.control.Label
        text65                          matlab.ui.control.Label
        uipanel9                        matlab.ui.container.ButtonGroup
        popupDropDuration               matlab.ui.control.DropDown
        btnOpenFolder                   matlab.ui.control.Button
        text64                          matlab.ui.control.Label
        text62                          matlab.ui.control.Label
        text61                          matlab.ui.control.Label
        text60                          matlab.ui.control.Label
        text59                          matlab.ui.control.Label
        editStartTime                   matlab.ui.control.EditField
        editTimeBetweenSets             matlab.ui.control.EditField
        editDropsPerSet                 matlab.ui.control.EditField
        chbInfineLoop                   matlab.ui.control.CheckBox
        text58                          matlab.ui.control.Label
        editResultsPath                 matlab.ui.control.EditField
        editStopTime                    matlab.ui.control.EditField
        uipanel8                        matlab.ui.container.Panel
        editSetNumber                   matlab.ui.control.EditField
        text81                          matlab.ui.control.Label
        editResultsCorrectedMeanGValue  matlab.ui.control.EditField
        editResultsDropsRejected        matlab.ui.control.EditField
        editResultsStandardDeviation    matlab.ui.control.EditField
        editResultsStandardError        matlab.ui.control.EditField
        editResultsMeanGValue           matlab.ui.control.EditField
        text57                          matlab.ui.control.Label
        text56                          matlab.ui.control.Label
        text55                          matlab.ui.control.Label
        text54                          matlab.ui.control.Label
        editResultsDropsTotal           matlab.ui.control.EditField
        text53                          matlab.ui.control.Label
        text52                          matlab.ui.control.Label
        axesGravityValues               matlab.ui.control.UIAxes
        zeroCrossingAxes2               matlab.ui.control.UIAxes
        axesResultsResiduals            matlab.ui.control.UIAxes
        zeroCrossingAxes1               matlab.ui.control.UIAxes
        axesResultsGValues              matlab.ui.control.UIAxes
    end

    
    methods (Access = private)
        function OpenInNewWindow(app, hAxes)
            global initializedAxes;
            figure;
            copyobj(findobj(hAxes, 'Type', 'line'), gca);
            copyobj(get(hAxes, 'Title'), gca);
            legendContent = get(legend(hAxes), 'String');
            if(~isempty(legendContent))
                legend(legendContent);
            end
            if(~isempty(find(initializedAxes == hAxes)))
                initializeAxesForLabels(gca);
            end
        end
        
        function popupSampling_Callback(app, hObject, eventdata, handles)
            global ExperimentParameters;
            ExperimentParameters.samplingFrequencyIndex = get(hObject, 'Value');
        end
        
    end
    

    % Callbacks that handle component events
    methods (Access = private)

        % Code that executes after component creation
        function GRGUI_OpeningFcn(app, varargin)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app); %#ok<ASGLU>
            
            global ExperimentParameters;
            global GraphicalObjects;
            global ExperimentResults;
            
            handles.output = hObject;
            guidata(hObject, handles);
            
            if(isempty(ExperimentParameters) == 1)
            
                %initialize settings
                ExperimentParameters.experimentRunning = 0;
                ExperimentParameters.samplingFrequencies = 100000000;
                ExperimentParameters.dropDurations = [60; 70; 80; 90; 95; 98; 100; 110; 120; 130; 140; 150; 160; 170];
                ExperimentParameters.dropDurationIndex = 6; % default 5
                ExperimentParameters.dropsPerSet = 16;
            %     ExperimentParameters.dropsPerSet = 25;
                ExperimentParameters.startTime = now;
                ExperimentParameters.stopTime = now+1/24/60;
            %     ExperimentParameters.timeBetweenSets = 1800;
                ExperimentParameters.timeBetweenSets = 1800;
                ExperimentParameters.AirPressureComNo = 'COM5'; %added by YJM, 2018.03.28
            %% Laser frequency
            %     ExperimentParameters.laserFrequency = 473.612452e12;   %% REO-1 laser, 2014.4
            %     ExperimentParameters.laserFrequency = 473.612507e12;   %% REO-2 laser
                ExperimentParameters.laserFrequency = 473.612461e12;   %% REO laser 34920-2617-812
            %     ExperimentParameters.laserFrequency = 473.612518e12;   %% 117 A laser
            %%
                ExperimentParameters.resultsPath = 'E:\T1_results';
            %     ExperimentParameters.resultsPath = 'E:\T2_results';
                ExperimentParameters.infiniteLoop = 1;
                ExperimentParameters.TriggerNormal = 1;
            
            %     ExperimentParameters.corrections.ExpectedGValue = 980122000; % NIM 1st floor: 980121365/1.027m
            %     ExperimentParameters.corrections.ExpectedGValue = 979365430; % XiAn_1 979365717/Ground
            %     ExperimentParameters.corrections.ExpectedGValue = 979361150; % XiAn_2
            %     ExperimentParameters.corrections.ExpectedGValue = 980097000; % Urumqi：980096989/1.21m
            %     ExperimentParameters.corrections.ExpectedGValue = 980060600; % Mulei：/1.21m
            %     ExperimentParameters.corrections.ExpectedGValue = 980143000; % Dushanzi：/1.21m
            %       ExperimentParameters.corrections.ExpectedGValue = 980509500; % Aletai暂用
            %     ExperimentParameters.corrections.ExpectedGValue = 980143700; % JMI
            %     ExperimentParameters.corrections.ExpectedGValue = 980137800; % TB01
            %     ExperimentParameters.corrections.ExpectedGValue=980125752.7; %TB01 HJG lager parameter
            %      ExperimentParameters.corrections.ExpectedGValue=980128006;%TB01 HJG samll parameter
            %      ExperimentParameters.corrections.ExpectedGValue=980144000;%TB01 HJG samll parameter
            %      ExperimentParameters.corrections.ExpectedGValue=980143000;%TB01 HJG samll parameter
                 ExperimentParameters.corrections.ExpectedGValue=980142800; % T1/TG-R1 HJG
            %     ExperimentParameters.corrections.ExpectedGValue = 980121300; % NIM_Changping
                %ExperimentParameters.corrections.ExpectedGValue = 980122580; % NIM_Changping, No.1, No.3, No.4
            %     ExperimentParameters.corrections.ExpectedGValue = 980122680; % NIM_Changping, No.8, No.9
            %      ExperimentParameters.corrections.ExpectedGValue=980109700; % T3
            %      baijiatuan
                ExperimentParameters.corrections.GValueTolerance = 1000;
            %     ExperimentParameters.corrections.GValueTolerance = 20000;
            
            %     ExperimentParameters.Location.longitude = 116.225;
            %     ExperimentParameters.Location.latitude = 40.2448;
            %     ExperimentParameters.Location.height = 121.51; % NIM 1st floor
            % %     ExperimentParameters.Location.height = 111.51; % NIM_Changping, No.1, No.3, No.4
            % % %     ExperimentParameters.Location.height = 111.21; % NIM_Changping, No.8, No.9
            %     ExperimentParameters.Location.gravityGradient = 280.0;  %NIM 1st floor
            % % %     ExperimentParameters.Location.gravityGradient = 267.0;  %NIM-Changping,NO.1
            % %      ExperimentParameters.Location.gravityGradient = 260.9;  %NIM-Changping,NO.2
            % %     ExperimentParameters.Location.gravityGradient = 261.3;  %NIM-Changping,NO.3
            % %     ExperimentParameters.Location.gravityGradient = 254.6;  %NIM-Changping,NO.4
            % % %     ExperimentParameters.Location.gravityGradient = 265.5;  %NIM-Changping,NO.8
            % % %     ExperimentParameters.Location.gravityGradient = 264.2;  %NIM-Changping,NO.9
            %     ExperimentParameters.Location.station = 'NIM';       %'NIM-Changping';
            
            %     ExperimentParameters.Location.longitude = 87.6006;
            %     ExperimentParameters.Location.latitude = 43.8081;
            %     ExperimentParameters.Location.height = 955;
            %     ExperimentParameters.Location.gravityGradient = 359.46;
            %     ExperimentParameters.Location.station = 'Urumqi';       %Urumqi红山
            
            %     ExperimentParameters.Location.longitude = 88.1349;
            %     ExperimentParameters.Location.latitude = 47.8556;
            %     ExperimentParameters.Location.height = 950;
            %     ExperimentParameters.Location.gravityGradient = 336;
            %     ExperimentParameters.Location.station = 'Aletai';       %Aletai
            
            %     ExperimentParameters.Location.longitude = 90.291;
            %     ExperimentParameters.Location.latitude = 43.809;
            %     ExperimentParameters.Location.height = 1404;
            %     ExperimentParameters.Location.gravityGradient = 343.26;
            %     ExperimentParameters.Location.station = 'Mulei';       % Mulei
            
            %     ExperimentParameters.Location.longitude = 84.886667;
            %     ExperimentParameters.Location.latitude = 44.311667;
            %     ExperimentParameters.Location.height = 767.0;
            %     ExperimentParameters.Location.gravityGradient = 300;  % 伍老师说先暂用
            %     ExperimentParameters.Location.station = 'Dushanzi';       % Dushanzi
            
            %     ExperimentParameters.Location.longitude = 108.9241;
            %     ExperimentParameters.Location.latitude = 34.0313;
            %     ExperimentParameters.Location.height = 658;
            %     ExperimentParameters.Location.gravityGradient = 238;
            %     ExperimentParameters.Location.station = 'XiAn_1';       %XiAn_1 979365717 地面 ；979365426.64/1.22m
            
            %     ExperimentParameters.Location.longitude = 108.9227;
            %     ExperimentParameters.Location.latitude = 34.0296;
            %     ExperimentParameters.Location.height = 617;
            %     ExperimentParameters.Location.gravityGradient = 238;  % 梯度先暂用
            %     ExperimentParameters.Location.station = 'XiAn_2';       %XiAn_2
            
            %     ExperimentParameters.Location.longitude = 116.32;
            %     ExperimentParameters.Location.latitude = 40.01;
            %     ExperimentParameters.Location.height = 50;
            %     ExperimentParameters.Location.gravityGradient = 280;
            %     ExperimentParameters.Location.station = 'JMI';       %'Tsinghua_JMI'
            
                ExperimentParameters.Location.longitude = 116.33;
                ExperimentParameters.Location.latitude = 40.00;
                ExperimentParameters.Location.height = 75;
                ExperimentParameters.Location.gravityGradient = 310.7;
                ExperimentParameters.Location.station = 'HJG';       %'Tsinghua_HJG'
            
            %   ExperimentParameters.Location.longitude = 6.1528;
            %   ExperimentParameters.Location.latitude = 49.6647;
            %   ExperimentParameters.Location.height = 295;
            %   ExperimentParameters.Location.gravityGradient = 262;
            %   ExperimentParameters.Location.station = 'Walferdange';     %'Luxembourg';
            
                ExperimentParameters.TriggerWait = 12;
            
                ExperimentResults.instrumentStatus = 'NA';
                ExperimentResults.SetNumber = 0;
            
                ExperimentResults.SingleDrop.dropNumber = 0;
                ExperimentResults.SingleDrop.currentGValue = 'NA';
                ExperimentResults.SingleDrop.meanGValueOfSet = 'NA';
                ExperimentResults.SingleDrop.solidTidesCorrection = 'NA';
                ExperimentResults.SingleDrop.standardDeviation = 0;
                ExperimentResults.SingleDrop.standardError = 0;
            
                ExperimentResults.Results.meanGValue = 'NA';
                ExperimentResults.Results.correctedMeanGValue = 'NA';
                ExperimentResults.Results.standardDeviation = 0;
                ExperimentResults.Results.standardError = 0;
                ExperimentResults.Results.dropsTotal = 0;
                ExperimentResults.Results.faildDropsTotal = 0;
                ExperimentResults.Results.dropsRejected = 0;
                
                %initializes the experiment parameters
                set(app.editStartTime, 'Value', datestr(ExperimentParameters.startTime, 'yyyy-mm-dd HH:MM'));
                set(app.editStopTime, 'Value', datestr(ExperimentParameters.stopTime, 'yyyy-mm-dd HH:MM'));
                set(app.editTimeBetweenSets, 'Value', num2str(ExperimentParameters.timeBetweenSets));
                set(app.editResultsPath, 'Value', num2str(ExperimentParameters.resultsPath));
                set(app.chbInfineLoop, 'Value', ExperimentParameters.infiniteLoop);
            
                %initialize location
                set(app.editLongitude, 'Value', num2str(ExperimentParameters.Location.longitude));
                set(app.editLatitude, 'Value', num2str(ExperimentParameters.Location.latitude));
                set(app.editHeight, 'Value', num2str(ExperimentParameters.Location.height));
                set(app.editGravityGradient, 'Value', num2str(ExperimentParameters.Location.gravityGradient));
                set(app.editStation, 'Value', ExperimentParameters.Location.station);
            
                %initialize corrections
                set(app.editExpectedGValue,'Value', num2str(ExperimentParameters.corrections.ExpectedGValue,10));
                set(app.editGValueTolerance,'Value', num2str(ExperimentParameters.corrections.GValueTolerance));
            
                %initialize single drop results
                set(app.editSingleDropDropNumber, 'Value',num2str(ExperimentResults.SingleDrop.dropNumber));
                set(app.editSingleDropCurrentGValue, 'Value',num2str(ExperimentResults.SingleDrop.currentGValue));
                set(app.editSetmeanZCGValue, 'Value',num2str(ExperimentResults.SingleDrop.meanGValueOfSet));
                set(app.editSetMeanSolidTidesCorrection, 'Value',num2str(ExperimentResults.SingleDrop.solidTidesCorrection));
                set(app.editStdDevMeanZCGValue, 'Value',num2str(ExperimentResults.SingleDrop.standardDeviation));
                set(app.editStandardErrorMZCMeanGValue, 'Value',num2str(ExperimentResults.SingleDrop.standardError));
            
                %initialize long term results
                set(app.editInstrumentStatus, 'Value',num2str(ExperimentResults.instrumentStatus));
                set(app.editSetNumber, 'Value',num2str(ExperimentResults.SetNumber));
                set(app.editResultsMeanGValue, 'Value',num2str(ExperimentResults.Results.meanGValue));
                set(app.editResultsCorrectedMeanGValue, 'Value',num2str(ExperimentResults.Results.correctedMeanGValue));
                set(app.editResultsStandardDeviation, 'Value',num2str(ExperimentResults.Results.standardDeviation));
                set(app.editResultsStandardError, 'Value',num2str(ExperimentResults.Results.standardError));
                set(app.editResultsDropsTotal, 'Value',num2str(ExperimentResults.Results.dropsTotal));
                set(app.editResultsDropsRejected, 'Value',num2str(ExperimentResults.Results.dropsRejected));
            
                %structure with handles to graphicalobjects - a nice hack :)
                GraphicalObjects.zeroCrossingAxes1 = app.zeroCrossingAxes1;
                GraphicalObjects.zeroCrossingAxes2 = app.zeroCrossingAxes2;
                GraphicalObjects.axesGravityValues = app.axesGravityValues;
                GraphicalObjects.axesResultsResiduals = app.axesResultsResiduals;
                GraphicalObjects.axesResultsGValues = app.axesResultsGValues;
            
                %%
                axes(GraphicalObjects.zeroCrossingAxes1);
                hold off;
                set(gca,'yticklabel',sprintf('%3.1f|',get(gca,'ytick')));
                xlabel('Drop length (ms)');
                ylabel('Residuals (nm)');
                grid on;
                hold on;
            
                axes(GraphicalObjects.zeroCrossingAxes2);
                hold off;
                set(gca,'yticklabel',sprintf('%3.1f|',get(gca,'ytick')));
                xlabel('Drop length (ms)');
                ylabel('Fringe envelop (V)');
                grid on;
            
                axes (GraphicalObjects.axesResultsGValues);
                hold off;
                set(gca,'yticklabel',sprintf('%5.1f|',get(gca,'ytick')));
                xlabel('Drop number');
                ylabel('Delta g / microgal');
                grid on;
                hold on;
            
                axes(GraphicalObjects.axesResultsResiduals);
                hold off;
                set(gca,'yticklabel',sprintf('%5.1f|',get(gca,'ytick')));
                xlabel('Set number');
                ylabel('Scatter / microgal');
                grid on;
                hold on;
            
                axes(GraphicalObjects.axesGravityValues);
                hold off;
                set(gca,'yticklabel',sprintf('%5.1f|',get(gca,'ytick')));
                xlabel('Set number');
                ylabel('Tides / microgal');
                grid on;
                hold on;
            
            end
            
            %loadnilib(); %!%
        end

        % Button pushed function: btnDZCEnvelopeFullScreen
        function btnDZCEnvelopeFullScreen_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global GraphicalObjects;
            OpenInNewWindow(app, GraphicalObjects.zeroCrossingAxes2);
        end

        % Button pushed function: btnDZCResidualsFullScreen
        function btnDZCResidualsFullScreen_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global GraphicalObjects;
            OpenInNewWindow(app, GraphicalObjects.zeroCrossingAxes1);
        end

        % Button pushed function: btnLoadGravityData
        function btnLoadGravityData_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global GraphicalObjects;
            OpenInNewWindow(app, GraphicalObjects.axesGravityValues);
        end

        % Button pushed function: btnOpenFolder
        function btnOpenFolder_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            path = uigetdir;
            if(path ~= 0)
                ExperimentParameters.resultsPath = path;
                set(app.editResultsPath, 'Value', path);
            end
        end

        % Button pushed function: btnResultsGValuesFullScreen
        function btnResultsGValuesFullScreen_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global GraphicalObjects;
            OpenInNewWindow(app, GraphicalObjects.axesResultsGValues);
        end

        % Button pushed function: btnResultsResidualsFullScreen
        function btnResultsResidualsFullScreen_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global GraphicalObjects;
            OpenInNewWindow(app, GraphicalObjects.axesResultsResiduals);
        end

        % Value changed function: btnStartStop
        function btnStartStop_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            global ExperimentResults;
            
            toogleState = get(hObject, 'Value');
            
            if(toogleState == 1)
                clc;
                set(hObject, 'String', 'Stop');
                pause(0.1);
            
                %% initialize the results
                ExperimentResults.instrumentStatus = 'NA';
                ExperimentResults.SetNumber = 0;
            
                ExperimentResults.SingleDrop.dropNumber = 0;
                ExperimentResults.SingleDrop.currentGValue = 'NA';
                ExperimentResults.SingleDrop.meanGValueOfSet = 'NA';
                ExperimentResults.SingleDrop.solidTidesCorrection = 'NA';
                ExperimentResults.SingleDrop.standardDeviation = 0;
                ExperimentResults.SingleDrop.standardError = 0;
            
                ExperimentResults.Results.meanGValue = 'NA';
                ExperimentResults.Results.correctedMeanGValue = 'NA';
                ExperimentResults.Results.standardDeviation = 0;
                ExperimentResults.Results.standardError = 0;
                ExperimentResults.Results.dropsTotal = 0;
                ExperimentResults.Results.faildDropsTotal = 0;
                ExperimentResults.Results.dropsRejected = 0;
            
                %initialize single drop results
                set(app.editSingleDropDropNumber, 'Value', num2str(ExperimentResults.SingleDrop.dropNumber));
                set(app.editSingleDropCurrentGValue, 'Value', num2str(ExperimentResults.SingleDrop.currentGValue));
                set(app.editSetmeanZCGValue, 'Value', num2str(ExperimentResults.SingleDrop.meanGValueOfSet));
                set(app.editSetMeanSolidTidesCorrection, 'Value', num2str(ExperimentResults.SingleDrop.solidTidesCorrection));
                set(app.editStdDevMeanZCGValue, 'Value', num2str(ExperimentResults.SingleDrop.standardDeviation));
                set(app.editStandardErrorMZCMeanGValue, 'Value', num2str(ExperimentResults.SingleDrop.standardError));
            
                %initialize long term results
                set(app.editInstrumentStatus, 'Value', num2str(ExperimentResults.instrumentStatus));
                set(app.editSetNumber, 'Value', num2str(ExperimentResults.SetNumber));
                set(app.editResultsMeanGValue, 'Value', num2str(ExperimentResults.Results.meanGValue));
                set(app.editResultsCorrectedMeanGValue, 'Value', num2str(ExperimentResults.Results.correctedMeanGValue));
                set(app.editResultsStandardDeviation, 'Value', num2str(ExperimentResults.Results.standardDeviation));
                set(app.editResultsStandardError, 'Value', num2str(ExperimentResults.Results.standardError));
                set(app.editResultsDropsTotal, 'Value', num2str(ExperimentResults.Results.dropsTotal));
                set(app.editResultsDropsRejected, 'Value', num2str(ExperimentResults.Results.dropsRejected));
            
                %%
                ExperimentParameters.experimentRunning = 1;
                ExperimentParameters.TriggerNormal = 1;
            
                MainFunction(app);
            
            else
                ExperimentParameters.experimentRunning = 0;
                set(hObject, 'String', 'Start');
                ports = instrfind;
                for i=1:length(ports)
                    status = get(ports(i),'Status');
                    if(strcmp(status, 'open') == 1)
                        fprintf(ports(i), 'srf-');
                        fclose(ports(i));
                    end
                end
                try
                    CsMl_FreeAllSystems;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                catch
                end
            end
        end

        % Value changed function: chbInfineLoop
        function chbInfineLoop_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.infiniteLoop = get(hObject, 'Value');
        end

        % Value changed function: editDropsPerSet
        function editDropsPerSet_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.dropsPerSet = str2double(get(hObject, 'String'));
        end

        % Value changed function: editExpectedGValue
        function editExpectedGValue_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.corrections.ExpectedGValue = str2double(get(hObject, 'String'));
        end

        % Value changed function: editGValueTolerance
        function editGValueTolerance_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.corrections.GValueTolerance = str2double(get(hObject, 'String'));
        end

        % Value changed function: editGravityGradient
        function editGravityGradient_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.Location.gravityGradient = str2double(get(hObject, 'String'));
        end

        % Value changed function: editHeight
        function editHeight_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.Location.height = str2double(get(hObject, 'String'));
        end

        % Value changed function: editLatitude
        function editLatitude_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.Location.latitude = str2double(get(hObject, 'String'));
        end

        % Value changed function: editLongitude
        function editLongitude_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.Location.longitude = str2double(get(hObject, 'String'));
        end

        % Value changed function: editStartTime
        function editStartTime_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.startTime = datenum(get(hObject, 'String'), 'yyyy-mm-dd HH:MM');
        end

        % Value changed function: editStation
        function editStation_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.Location.station = get(hObject, 'String');
        end

        % Value changed function: editStopTime
        function editStopTime_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.stopTime = datenum(get(hObject, 'String'), 'yyyy-mm-dd HH:MM');
        end

        % Value changed function: editTimeBetweenSets
        function editTimeBetweenSets_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.timeBetweenSets = str2double(get(hObject, 'String'));
        end

        % Close request function: figure1
        function figure1_CloseRequestFcn(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            delete(hObject);
            clear all;
            try
                CsMl_FreeAllSystems;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                ports = instrfind;
                for i=1:length(ports)
                    status = get(ports(i),'Status');
                    if(strcmp(status, 'open') == 1)
                        fprintf(ports(i), 'srf-');
                        fclose(ports(i));
                    end
                end
            catch
            end
        end

        % Value changed function: popupDropDuration
        function popupDropDuration_Callback(app, event)
            % Create GUIDE-style callback args - Added by Migration Tool
            [hObject, eventdata, handles] = convertToGUIDECallbackArguments(app, event); %#ok<ASGLU>
            
            global ExperimentParameters;
            ExperimentParameters.dropDurationIndex = get(hObject, 'Value');
        end
    end

    % Component initialization
    methods (Access = private)

        % Create UIFigure and components
        function createComponents(app)

            % Create figure1 and hide until all components are created
            app.figure1 = uifigure('Visible', 'off');
            app.figure1.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
            app.figure1.Position = [0 0 1000 680];
            app.figure1.Name = 'GRGUI';
            app.figure1.CloseRequestFcn = createCallbackFcn(app, @figure1_CloseRequestFcn, true);
            app.figure1.HandleVisibility = 'callback';
            app.figure1.Tag = 'figure1';

            % Create uitoolbar1
            app.uitoolbar1 = uitoolbar(app.figure1);
            app.uitoolbar1.Tag = 'uitoolbar1';

            % Create uipanel
            app.uipanel = uibuttongroup(app.figure1);
            app.uipanel.Title = 'T-1A  Absolute Gravimeter';
            app.uipanel.Tag = 'uipanel';
            app.uipanel.Scrollable = 'on';
            app.uipanel.FontSize = 18.6666666666667;
            app.uipanel.Position = [1 -25 992 703];

            % Create axesResultsGValues
            app.axesResultsGValues = uiaxes(app.uipanel);
            app.axesResultsGValues.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
            app.axesResultsGValues.XTick = [0 0.2 0.4 0.6 0.8 1];
            app.axesResultsGValues.YTick = [0 0.2 0.4 0.6 0.8 1];
            app.axesResultsGValues.FontSize = 13.3333333333333;
            app.axesResultsGValues.NextPlot = 'replace';
            app.axesResultsGValues.Tag = 'axesResultsGValues';
            app.axesResultsGValues.Position = [24 121 353 257];

            % Create zeroCrossingAxes1
            app.zeroCrossingAxes1 = uiaxes(app.uipanel);
            app.zeroCrossingAxes1.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
            app.zeroCrossingAxes1.FontSize = 10.6666666666667;
            app.zeroCrossingAxes1.NextPlot = 'replace';
            app.zeroCrossingAxes1.Tag = 'zeroCrossingAxes1';
            app.zeroCrossingAxes1.Position = [402 253 231 125];

            % Create axesResultsResiduals
            app.axesResultsResiduals = uiaxes(app.uipanel);
            app.axesResultsResiduals.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
            app.axesResultsResiduals.FontSize = 10.6666666666667;
            app.axesResultsResiduals.NextPlot = 'replace';
            app.axesResultsResiduals.Tag = 'axesResultsResiduals';
            app.axesResultsResiduals.Position = [684 253 239 125];

            % Create zeroCrossingAxes2
            app.zeroCrossingAxes2 = uiaxes(app.uipanel);
            app.zeroCrossingAxes2.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
            app.zeroCrossingAxes2.FontSize = 10.6666666666667;
            app.zeroCrossingAxes2.NextPlot = 'replace';
            app.zeroCrossingAxes2.Tag = 'zeroCrossingAxes2';
            app.zeroCrossingAxes2.Position = [401 126 231 125];

            % Create axesGravityValues
            app.axesGravityValues = uiaxes(app.uipanel);
            app.axesGravityValues.Colormap = [0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0];
            app.axesGravityValues.FontSize = 10.6666666666667;
            app.axesGravityValues.NextPlot = 'replace';
            app.axesGravityValues.Tag = 'axesGravityValues';
            app.axesGravityValues.Position = [682 126 240 125];

            % Create uipanel8
            app.uipanel8 = uipanel(app.uipanel);
            app.uipanel8.Title = 'Long term measurement results (microgal)';
            app.uipanel8.Tag = 'uipanel8';
            app.uipanel8.FontWeight = 'bold';
            app.uipanel8.FontSize = 16;
            app.uipanel8.Position = [24 378 942 89];

            % Create text52
            app.text52 = uilabel(app.uipanel8);
            app.text52.Tag = 'text52';
            app.text52.VerticalAlignment = 'top';
            app.text52.WordWrap = 'on';
            app.text52.FontSize = 13.3333333333333;
            app.text52.Position = [455 30 93.8666666666667 21.4358974358974];
            app.text52.Text = 'Sets mean g';

            % Create text53
            app.text53 = uilabel(app.uipanel8);
            app.text53.Tag = 'text53';
            app.text53.VerticalAlignment = 'top';
            app.text53.WordWrap = 'on';
            app.text53.FontSize = 13.3333333333333;
            app.text53.Position = [377 10 176 21.4358974358974];
            app.text53.Text = 'Corrected Sets mean g';

            % Create editResultsDropsTotal
            app.editResultsDropsTotal = uieditfield(app.uipanel8, 'text');
            app.editResultsDropsTotal.Tag = 'editResultsDropsTotal';
            app.editResultsDropsTotal.HorizontalAlignment = 'right';
            app.editResultsDropsTotal.FontSize = 10.6666666666667;
            app.editResultsDropsTotal.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editResultsDropsTotal.Tooltip = 'Show total number of drops.';
            app.editResultsDropsTotal.Position = [281 35 93 21];
            app.editResultsDropsTotal.Value = '0';

            % Create text54
            app.text54 = uilabel(app.uipanel8);
            app.text54.Tag = 'text54';
            app.text54.VerticalAlignment = 'top';
            app.text54.WordWrap = 'on';
            app.text54.FontSize = 13.3333333333333;
            app.text54.Position = [674 30 116.266666666667 21.4358974358974];
            app.text54.Text = 'Standard deviation';

            % Create text55
            app.text55 = uilabel(app.uipanel8);
            app.text55.Tag = 'text55';
            app.text55.VerticalAlignment = 'top';
            app.text55.WordWrap = 'on';
            app.text55.FontSize = 13.3333333333333;
            app.text55.Position = [674 10 117.333333333333 21.4358974358974];
            app.text55.Text = 'Standard error';

            % Create text56
            app.text56 = uilabel(app.uipanel8);
            app.text56.Tag = 'text56';
            app.text56.VerticalAlignment = 'top';
            app.text56.WordWrap = 'on';
            app.text56.FontSize = 13.3333333333333;
            app.text56.Position = [168 34 96 21];
            app.text56.Text = 'Drops total';

            % Create text57
            app.text57 = uilabel(app.uipanel8);
            app.text57.Tag = 'text57';
            app.text57.VerticalAlignment = 'top';
            app.text57.WordWrap = 'on';
            app.text57.FontSize = 13.3333333333333;
            app.text57.Position = [137 10 128 21];
            app.text57.Text = 'Drops rejected [%]';

            % Create editResultsMeanGValue
            app.editResultsMeanGValue = uieditfield(app.uipanel8, 'text');
            app.editResultsMeanGValue.Tag = 'editResultsMeanGValue';
            app.editResultsMeanGValue.HorizontalAlignment = 'right';
            app.editResultsMeanGValue.FontSize = 10.6666666666667;
            app.editResultsMeanGValue.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editResultsMeanGValue.Tooltip = 'Shows the mean g value of the measured data.';
            app.editResultsMeanGValue.Position = [557 32 93 21];
            app.editResultsMeanGValue.Value = 'NA';

            % Create editResultsStandardError
            app.editResultsStandardError = uieditfield(app.uipanel8, 'text');
            app.editResultsStandardError.Tag = 'editResultsStandardError';
            app.editResultsStandardError.HorizontalAlignment = 'right';
            app.editResultsStandardError.FontSize = 10.6666666666667;
            app.editResultsStandardError.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editResultsStandardError.Tooltip = 'Shows standard error  of the measurement.';
            app.editResultsStandardError.Position = [801 10 93 21];
            app.editResultsStandardError.Value = '0';

            % Create editResultsStandardDeviation
            app.editResultsStandardDeviation = uieditfield(app.uipanel8, 'text');
            app.editResultsStandardDeviation.Tag = 'editResultsStandardDeviation';
            app.editResultsStandardDeviation.HorizontalAlignment = 'right';
            app.editResultsStandardDeviation.FontSize = 10.6666666666667;
            app.editResultsStandardDeviation.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editResultsStandardDeviation.Tooltip = 'Shows the standard deviation of the measurement.';
            app.editResultsStandardDeviation.Position = [801 32 93 21];
            app.editResultsStandardDeviation.Value = '0';

            % Create editResultsDropsRejected
            app.editResultsDropsRejected = uieditfield(app.uipanel8, 'text');
            app.editResultsDropsRejected.Tag = 'editResultsDropsRejected';
            app.editResultsDropsRejected.HorizontalAlignment = 'right';
            app.editResultsDropsRejected.FontSize = 10.6666666666667;
            app.editResultsDropsRejected.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editResultsDropsRejected.Tooltip = 'Shows precentage of rejected drops.';
            app.editResultsDropsRejected.Position = [281 12 93 21];
            app.editResultsDropsRejected.Value = '0';

            % Create editResultsCorrectedMeanGValue
            app.editResultsCorrectedMeanGValue = uieditfield(app.uipanel8, 'text');
            app.editResultsCorrectedMeanGValue.Tag = 'editResultsCorrectedMeanGValue';
            app.editResultsCorrectedMeanGValue.HorizontalAlignment = 'right';
            app.editResultsCorrectedMeanGValue.FontSize = 10.6666666666667;
            app.editResultsCorrectedMeanGValue.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editResultsCorrectedMeanGValue.Tooltip = 'Shows the corrected mean g value of the measured data.';
            app.editResultsCorrectedMeanGValue.Position = [557 10 93 21];
            app.editResultsCorrectedMeanGValue.Value = 'NA';

            % Create text81
            app.text81 = uilabel(app.uipanel8);
            app.text81.Tag = 'text81';
            app.text81.VerticalAlignment = 'top';
            app.text81.WordWrap = 'on';
            app.text81.FontSize = 13.3333333333333;
            app.text81.Position = [3 21 54.4 21.4358974358974];
            app.text81.Text = 'Set No.';

            % Create editSetNumber
            app.editSetNumber = uieditfield(app.uipanel8, 'text');
            app.editSetNumber.Tag = 'editSetNumber';
            app.editSetNumber.HorizontalAlignment = 'right';
            app.editSetNumber.FontSize = 10.6666666666667;
            app.editSetNumber.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editSetNumber.Tooltip = 'Shows the the total set number.';
            app.editSetNumber.Position = [63 21 62 21];
            app.editSetNumber.Value = '0';

            % Create uipanel9
            app.uipanel9 = uibuttongroup(app.uipanel);
            app.uipanel9.Title = 'Setup';
            app.uipanel9.Tag = 'uipanel9';
            app.uipanel9.FontWeight = 'bold';
            app.uipanel9.FontSize = 16;
            app.uipanel9.Position = [27 466 356 183];

            % Create editStopTime
            app.editStopTime = uieditfield(app.uipanel9, 'text');
            app.editStopTime.ValueChangedFcn = createCallbackFcn(app, @editStopTime_Callback, true);
            app.editStopTime.Tag = 'editStopTime';
            app.editStopTime.FontSize = 10.6666666666667;
            app.editStopTime.Tooltip = 'Sets the time when the experiment should stop.';
            app.editStopTime.Position = [143 34.9999999999999 101 21];
            app.editStopTime.Value = '2012-06-06 08:08';

            % Create editResultsPath
            app.editResultsPath = uieditfield(app.uipanel9, 'text');
            app.editResultsPath.Tag = 'editResultsPath';
            app.editResultsPath.FontSize = 10.6666666666667;
            app.editResultsPath.Tooltip = 'Sets the path where the results are stored.#';
            app.editResultsPath.Position = [143 14.9999999999999 101 21];
            app.editResultsPath.Value = 'D:\T1_results';

            % Create text58
            app.text58 = uilabel(app.uipanel9);
            app.text58.Tag = 'text58';
            app.text58.VerticalAlignment = 'top';
            app.text58.WordWrap = 'on';
            app.text58.FontSize = 13.3333333333333;
            app.text58.Position = [33 107.051282051282 115.2 21.4358974358974];
            app.text58.Text = 'Drop/Set';

            % Create chbInfineLoop
            app.chbInfineLoop = uicheckbox(app.uipanel9);
            app.chbInfineLoop.ValueChangedFcn = createCallbackFcn(app, @chbInfineLoop_Callback, true);
            app.chbInfineLoop.Tag = 'chbInfineLoop';
            app.chbInfineLoop.Tooltip = 'Sets whether experiment should run forever.';
            app.chbInfineLoop.Text = 'Infinite';
            app.chbInfineLoop.FontSize = 13.3333333333333;
            app.chbInfineLoop.Position = [259 36.9999999999999 66 25];

            % Create editDropsPerSet
            app.editDropsPerSet = uieditfield(app.uipanel9, 'text');
            app.editDropsPerSet.ValueChangedFcn = createCallbackFcn(app, @editDropsPerSet_Callback, true);
            app.editDropsPerSet.Tag = 'editDropsPerSet';
            app.editDropsPerSet.FontSize = 10.6666666666667;
            app.editDropsPerSet.Tooltip = 'Set the number of drops in a set.';
            app.editDropsPerSet.Position = [143 94.9999999999999 101 21];
            app.editDropsPerSet.Value = '16';

            % Create editTimeBetweenSets
            app.editTimeBetweenSets = uieditfield(app.uipanel9, 'text');
            app.editTimeBetweenSets.ValueChangedFcn = createCallbackFcn(app, @editTimeBetweenSets_Callback, true);
            app.editTimeBetweenSets.Tag = 'editTimeBetweenSets';
            app.editTimeBetweenSets.FontSize = 10.6666666666667;
            app.editTimeBetweenSets.Tooltip = 'Sets the time between the beginning of each set.';
            app.editTimeBetweenSets.Position = [143 74.9999999999999 101 21];
            app.editTimeBetweenSets.Value = '1800';

            % Create editStartTime
            app.editStartTime = uieditfield(app.uipanel9, 'text');
            app.editStartTime.ValueChangedFcn = createCallbackFcn(app, @editStartTime_Callback, true);
            app.editStartTime.Tag = 'editStartTime';
            app.editStartTime.FontSize = 10.6666666666667;
            app.editStartTime.Tooltip = 'Sets the time of the first drop. If the time is less then the current time experiment will start immidiately.';
            app.editStartTime.Position = [143 54.9999999999999 101 21];
            app.editStartTime.Value = '2012-06-06 08:08';

            % Create text59
            app.text59 = uilabel(app.uipanel9);
            app.text59.Tag = 'text59';
            app.text59.VerticalAlignment = 'top';
            app.text59.WordWrap = 'on';
            app.text59.FontSize = 13.3333333333333;
            app.text59.Position = [31.9333333333333 84.4871794871795 116.266666666667 21.4358974358974];
            app.text59.Text = 'Sets Interval [s]';

            % Create text60
            app.text60 = uilabel(app.uipanel9);
            app.text60.Tag = 'text60';
            app.text60.VerticalAlignment = 'top';
            app.text60.WordWrap = 'on';
            app.text60.FontSize = 13.3333333333333;
            app.text60.Position = [31.9333333333333 61.9230769230769 117.333333333333 21.4358974358974];
            app.text60.Text = 'Starting Time';

            % Create text61
            app.text61 = uilabel(app.uipanel9);
            app.text61.Tag = 'text61';
            app.text61.VerticalAlignment = 'top';
            app.text61.WordWrap = 'on';
            app.text61.FontSize = 13.3333333333333;
            app.text61.Position = [31.9333333333333 39.3589743589743 117.333333333333 21.4358974358974];
            app.text61.Text = 'Stopping Time';

            % Create text62
            app.text62 = uilabel(app.uipanel9);
            app.text62.Tag = 'text62';
            app.text62.VerticalAlignment = 'top';
            app.text62.WordWrap = 'on';
            app.text62.FontSize = 13.3333333333333;
            app.text62.Position = [31.9333333333333 16.7948717948717 117.333333333333 21.4358974358974];
            app.text62.Text = 'Save results in';

            % Create text64
            app.text64 = uilabel(app.uipanel9);
            app.text64.Tag = 'text64';
            app.text64.VerticalAlignment = 'top';
            app.text64.WordWrap = 'on';
            app.text64.FontSize = 13.3333333333333;
            app.text64.Position = [33 129.615384615385 115.2 21.4358974358974];
            app.text64.Text = 'Drop Length [ms]';

            % Create btnOpenFolder
            app.btnOpenFolder = uibutton(app.uipanel9, 'push');
            app.btnOpenFolder.ButtonPushedFcn = createCallbackFcn(app, @btnOpenFolder_Callback, true);
            app.btnOpenFolder.Tag = 'btnOpenFolder';
            app.btnOpenFolder.FontSize = 10.6666666666667;
            app.btnOpenFolder.Tooltip = 'Allows to choose the path where to store the results.';
            app.btnOpenFolder.Position = [258 12.9999999999999 24 24];
            app.btnOpenFolder.Text = '...';

            % Create popupDropDuration
            app.popupDropDuration = uidropdown(app.uipanel9);
            app.popupDropDuration.Items = {'100', '110', '120', '130', '140', '150', '160'};
            app.popupDropDuration.ValueChangedFcn = createCallbackFcn(app, @popupDropDuration_Callback, true);
            app.popupDropDuration.Tag = 'popupDropDuration';
            app.popupDropDuration.Tooltip = 'Sets the aquisition time.';
            app.popupDropDuration.FontSize = 10.6666666666667;
            app.popupDropDuration.BackgroundColor = [1 1 1];
            app.popupDropDuration.Position = [143 116 101 21];
            app.popupDropDuration.Value = '100';

            % Create uipanel10
            app.uipanel10 = uipanel(app.uipanel);
            app.uipanel10.Title = 'Site';
            app.uipanel10.Tag = 'uipanel10';
            app.uipanel10.FontWeight = 'bold';
            app.uipanel10.FontSize = 16;
            app.uipanel10.Position = [395 549 565 100];

            % Create text65
            app.text65 = uilabel(app.uipanel10);
            app.text65.Tag = 'text65';
            app.text65.VerticalAlignment = 'top';
            app.text65.WordWrap = 'on';
            app.text65.FontSize = 13.3333333333333;
            app.text65.Position = [35.1333333333333 54.0256410256414 107.733333333333 21.4358974358974];
            app.text65.Text = 'Latitude';

            % Create text66
            app.text66 = uilabel(app.uipanel10);
            app.text66.Tag = 'text66';
            app.text66.VerticalAlignment = 'top';
            app.text66.WordWrap = 'on';
            app.text66.FontSize = 13.3333333333333;
            app.text66.Position = [35.1333333333333 31.4615384615385 107.733333333333 21.4358974358974];
            app.text66.Text = 'Longitude';

            % Create text67
            app.text67 = uilabel(app.uipanel10);
            app.text67.Tag = 'text67';
            app.text67.VerticalAlignment = 'top';
            app.text67.WordWrap = 'on';
            app.text67.FontSize = 13.3333333333333;
            app.text67.Position = [35.1333333333333 8.8974358974359 107.733333333333 21.4358974358974];
            app.text67.Text = 'Height [m]';

            % Create text68
            app.text68 = uilabel(app.uipanel10);
            app.text68.Tag = 'text68';
            app.text68.VerticalAlignment = 'top';
            app.text68.WordWrap = 'on';
            app.text68.FontSize = 13.3333333333333;
            app.text68.Position = [217.533333333336 54.0256410256412 107.733333333333 21.4358974358974];
            app.text68.Text = 'Station';

            % Create text69
            app.text69 = uilabel(app.uipanel10);
            app.text69.Tag = 'text69';
            app.text69.VerticalAlignment = 'top';
            app.text69.WordWrap = 'on';
            app.text69.FontSize = 13.3333333333333;
            app.text69.Position = [217.533333333336 8.89743589743596 107.733333333333 21.4358974358974];
            app.text69.Text = 'g value rang';

            % Create editStation
            app.editStation = uieditfield(app.uipanel10, 'text');
            app.editStation.ValueChangedFcn = createCallbackFcn(app, @editStation_Callback, true);
            app.editStation.Tag = 'editStation';
            app.editStation.HorizontalAlignment = 'center';
            app.editStation.FontSize = 10.6666666666667;
            app.editStation.Tooltip = 'Sets the name of the station.';
            app.editStation.Position = [321 48 106 21];
            app.editStation.Value = 'NIM';

            % Create editGravityGradient
            app.editGravityGradient = uieditfield(app.uipanel10, 'text');
            app.editGravityGradient.ValueChangedFcn = createCallbackFcn(app, @editGravityGradient_Callback, true);
            app.editGravityGradient.Tag = 'editGravityGradient';
            app.editGravityGradient.HorizontalAlignment = 'center';
            app.editGravityGradient.FontSize = 10.6666666666667;
            app.editGravityGradient.Tooltip = 'Sets the gravity gradient for the experiment.#';
            app.editGravityGradient.Position = [321 28 106 21];
            app.editGravityGradient.Value = '280';

            % Create text70
            app.text70 = uilabel(app.uipanel10);
            app.text70.Tag = 'text70';
            app.text70.VerticalAlignment = 'top';
            app.text70.WordWrap = 'on';
            app.text70.FontSize = 13.3333333333333;
            app.text70.Position = [217.533333333336 31.4615384615386 118.4 21.4358974358974];
            app.text70.Text = 'grad. [microgal/m]';

            % Create editHeight
            app.editHeight = uieditfield(app.uipanel10, 'text');
            app.editHeight.ValueChangedFcn = createCallbackFcn(app, @editHeight_Callback, true);
            app.editHeight.Tag = 'editHeight';
            app.editHeight.HorizontalAlignment = 'center';
            app.editHeight.FontSize = 10.6666666666667;
            app.editHeight.Tooltip = 'Allow to set the height above sea level for correct solid tides calculations.';
            app.editHeight.Position = [106 8.00000000000007 64 21];
            app.editHeight.Value = '124';

            % Create editLongitude
            app.editLongitude = uieditfield(app.uipanel10, 'text');
            app.editLongitude.ValueChangedFcn = createCallbackFcn(app, @editLongitude_Callback, true);
            app.editLongitude.Tag = 'editLongitude';
            app.editLongitude.HorizontalAlignment = 'center';
            app.editLongitude.FontSize = 10.6666666666667;
            app.editLongitude.Tooltip = 'Allow to set the geographical longitude for correct solid tides calculations.';
            app.editLongitude.Position = [106 28.0000000000001 64 21];
            app.editLongitude.Value = '116.225';

            % Create editExpectedGValue
            app.editExpectedGValue = uieditfield(app.uipanel10, 'text');
            app.editExpectedGValue.ValueChangedFcn = createCallbackFcn(app, @editExpectedGValue_Callback, true);
            app.editExpectedGValue.Tag = 'editExpectedGValue';
            app.editExpectedGValue.HorizontalAlignment = 'center';
            app.editExpectedGValue.FontSize = 10.6666666666667;
            app.editExpectedGValue.Position = [321 8 106 21];
            app.editExpectedGValue.Value = '980000000';

            % Create text71
            app.text71 = uilabel(app.uipanel10);
            app.text71.Tag = 'text71';
            app.text71.VerticalAlignment = 'top';
            app.text71.WordWrap = 'on';
            app.text71.FontSize = 16;
            app.text71.Position = [462.866666666669 8.89743589743598 27.7333333333333 21.4358974358974];
            app.text71.Text = '+/-';

            % Create editGValueTolerance
            app.editGValueTolerance = uieditfield(app.uipanel10, 'text');
            app.editGValueTolerance.ValueChangedFcn = createCallbackFcn(app, @editGValueTolerance_Callback, true);
            app.editGValueTolerance.Tag = 'editGValueTolerance';
            app.editGValueTolerance.HorizontalAlignment = 'center';
            app.editGValueTolerance.FontSize = 10.6666666666667;
            app.editGValueTolerance.Position = [462.000000000001 8.00000000000007 45 21];
            app.editGValueTolerance.Value = '500';

            % Create editLatitude
            app.editLatitude = uieditfield(app.uipanel10, 'text');
            app.editLatitude.ValueChangedFcn = createCallbackFcn(app, @editLatitude_Callback, true);
            app.editLatitude.Tag = 'editLatitude';
            app.editLatitude.HorizontalAlignment = 'center';
            app.editLatitude.FontSize = 10.6666666666667;
            app.editLatitude.Tooltip = 'Allow to set the geographical latitude for correct solid tides calculations.';
            app.editLatitude.Position = [106 48.0000000000002 64 21];
            app.editLatitude.Value = '40.245';

            % Create uipanel11
            app.uipanel11 = uipanel(app.uipanel);
            app.uipanel11.Title = 'Measured g values (microgal)';
            app.uipanel11.Tag = 'uipanel11';
            app.uipanel11.FontWeight = 'bold';
            app.uipanel11.FontSize = 16;
            app.uipanel11.Position = [395 466 566 85];

            % Create text72
            app.text72 = uilabel(app.uipanel11);
            app.text72.Tag = 'text72';
            app.text72.VerticalAlignment = 'top';
            app.text72.WordWrap = 'on';
            app.text72.FontSize = 13.3333333333333;
            app.text72.Position = [6 33 107.733333333333 21.4358974358974];
            app.text72.Text = 'Drop No.';

            % Create text73
            app.text73 = uilabel(app.uipanel11);
            app.text73.Tag = 'text73';
            app.text73.VerticalAlignment = 'top';
            app.text73.WordWrap = 'on';
            app.text73.FontSize = 13.3333333333333;
            app.text73.Position = [6 7 107.733333333333 21.4358974358974];
            app.text73.Text = 'Std. of drop';

            % Create text74
            app.text74 = uilabel(app.uipanel11);
            app.text74.Tag = 'text74';
            app.text74.VerticalAlignment = 'top';
            app.text74.WordWrap = 'on';
            app.text74.FontSize = 13.3333333333333;
            app.text74.Position = [168 33 94.9333333333334 21.4358974358974];
            app.text74.Text = 'Std. of mean';

            % Create text75
            app.text75 = uilabel(app.uipanel11);
            app.text75.Tag = 'text75';
            app.text75.VerticalAlignment = 'top';
            app.text75.WordWrap = 'on';
            app.text75.FontSize = 13.3333333333333;
            app.text75.Position = [330 27 58.6666666666667 21.4358974358974];
            app.text75.Text = 'Current g';

            % Create text76
            app.text76 = uilabel(app.uipanel11);
            app.text76.Tag = 'text76';
            app.text76.VerticalAlignment = 'top';
            app.text76.WordWrap = 'on';
            app.text76.FontSize = 13.3333333333333;
            app.text76.Position = [333 6 50.1333333333334 21.4358974358974];
            app.text76.Text = 'Mean g';

            % Create editSingleDropCurrentGValue
            app.editSingleDropCurrentGValue = uieditfield(app.uipanel11, 'text');
            app.editSingleDropCurrentGValue.Tag = 'editSingleDropCurrentGValue';
            app.editSingleDropCurrentGValue.HorizontalAlignment = 'right';
            app.editSingleDropCurrentGValue.FontSize = 10.6666666666667;
            app.editSingleDropCurrentGValue.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editSingleDropCurrentGValue.Tooltip = 'Shows the g value for this drop. The value is not corrected.';
            app.editSingleDropCurrentGValue.Position = [419 31 123 21];
            app.editSingleDropCurrentGValue.Value = 'NA';

            % Create editStandardErrorMZCMeanGValue
            app.editStandardErrorMZCMeanGValue = uieditfield(app.uipanel11, 'text');
            app.editStandardErrorMZCMeanGValue.Tag = 'editStandardErrorMZCMeanGValue';
            app.editStandardErrorMZCMeanGValue.HorizontalAlignment = 'right';
            app.editStandardErrorMZCMeanGValue.FontSize = 10.6666666666667;
            app.editStandardErrorMZCMeanGValue.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editStandardErrorMZCMeanGValue.Tooltip = 'Shows standard error for this set';
            app.editStandardErrorMZCMeanGValue.Position = [268 30 48 20];
            app.editStandardErrorMZCMeanGValue.Value = '0';

            % Create editStdDevMeanZCGValue
            app.editStdDevMeanZCGValue = uieditfield(app.uipanel11, 'text');
            app.editStdDevMeanZCGValue.Tag = 'editStdDevMeanZCGValue';
            app.editStdDevMeanZCGValue.HorizontalAlignment = 'right';
            app.editStdDevMeanZCGValue.FontSize = 10.6666666666667;
            app.editStdDevMeanZCGValue.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editStdDevMeanZCGValue.Tooltip = 'Shows the standard deviation of this set';
            app.editStdDevMeanZCGValue.Position = [112 7 48 21];
            app.editStdDevMeanZCGValue.Value = '0';

            % Create editSingleDropDropNumber
            app.editSingleDropDropNumber = uieditfield(app.uipanel11, 'text');
            app.editSingleDropDropNumber.Tag = 'editSingleDropDropNumber';
            app.editSingleDropDropNumber.HorizontalAlignment = 'right';
            app.editSingleDropDropNumber.FontSize = 10.6666666666667;
            app.editSingleDropDropNumber.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editSingleDropDropNumber.Tooltip = 'Shows the the current drop in the set.';
            app.editSingleDropDropNumber.Position = [112 33 48 21];
            app.editSingleDropDropNumber.Value = '0';

            % Create editSetmeanZCGValue
            app.editSetmeanZCGValue = uieditfield(app.uipanel11, 'text');
            app.editSetmeanZCGValue.Tag = 'editSetmeanZCGValue';
            app.editSetmeanZCGValue.HorizontalAlignment = 'right';
            app.editSetmeanZCGValue.FontSize = 10.6666666666667;
            app.editSetmeanZCGValue.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editSetmeanZCGValue.Tooltip = 'Shows the mean value for this set';
            app.editSetmeanZCGValue.Position = [419 7 123 21];
            app.editSetmeanZCGValue.Value = 'NA';

            % Create editSetMeanSolidTidesCorrection
            app.editSetMeanSolidTidesCorrection = uieditfield(app.uipanel11, 'text');
            app.editSetMeanSolidTidesCorrection.Tag = 'editSetMeanSolidTidesCorrection';
            app.editSetMeanSolidTidesCorrection.HorizontalAlignment = 'right';
            app.editSetMeanSolidTidesCorrection.FontSize = 10.6666666666667;
            app.editSetMeanSolidTidesCorrection.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editSetMeanSolidTidesCorrection.Tooltip = 'Shows mean value of influence of solid tides on a g value.';
            app.editSetMeanSolidTidesCorrection.Position = [268 7 48 21];
            app.editSetMeanSolidTidesCorrection.Value = 'NA';

            % Create text82
            app.text82 = uilabel(app.uipanel11);
            app.text82.Tag = 'text82';
            app.text82.VerticalAlignment = 'top';
            app.text82.WordWrap = 'on';
            app.text82.FontSize = 13.3333333333333;
            app.text82.Position = [168 7 71.4666666666666 21.4358974358974];
            app.text82.Text = 'Solid Tides';

            % Create uipanel12
            app.uipanel12 = uipanel(app.uipanel);
            app.uipanel12.Title = 'Operation';
            app.uipanel12.Tag = 'uipanel12';
            app.uipanel12.FontWeight = 'bold';
            app.uipanel12.FontSize = 16;
            app.uipanel12.Position = [19 48 941 61];

            % Create editInstrumentStatus
            app.editInstrumentStatus = uieditfield(app.uipanel12, 'text');
            app.editInstrumentStatus.Tag = 'editInstrumentStatus';
            app.editInstrumentStatus.HorizontalAlignment = 'right';
            app.editInstrumentStatus.FontSize = 10.6666666666667;
            app.editInstrumentStatus.BackgroundColor = [0.905882352941176 0.905882352941176 0.905882352941176];
            app.editInstrumentStatus.Enable = 'off';
            app.editInstrumentStatus.Tooltip = 'Shows the current status of experiment.';
            app.editInstrumentStatus.Position = [218 9 428 23];
            app.editInstrumentStatus.Value = 'NA';

            % Create btnStartStop
            app.btnStartStop = uibutton(app.uipanel12, 'state');
            app.btnStartStop.ValueChangedFcn = createCallbackFcn(app, @btnStartStop_Callback, true);
            app.btnStartStop.Tag = 'btnStartStop';
            app.btnStartStop.Tooltip = 'Starts and stops the experiment.';
            app.btnStartStop.Text = 'Start';
            app.btnStartStop.FontSize = 13.3333333333333;
            app.btnStartStop.FontWeight = 'bold';
            app.btnStartStop.FontColor = [1 0 0];
            app.btnStartStop.Position = [705 7 145 27];

            % Create text79
            app.text79 = uilabel(app.uipanel12);
            app.text79.Tag = 'text79';
            app.text79.VerticalAlignment = 'top';
            app.text79.WordWrap = 'on';
            app.text79.FontSize = 13.3333333333333;
            app.text79.Position = [36.9999999999999 8.99999999999991 143 19];
            app.text79.Text = 'Measurement status :';

            % Create btnResultsGValuesFullScreen
            app.btnResultsGValuesFullScreen = uibutton(app.uipanel, 'push');
            app.btnResultsGValuesFullScreen.ButtonPushedFcn = createCallbackFcn(app, @btnResultsGValuesFullScreen_Callback, true);
            app.btnResultsGValuesFullScreen.Tag = 'btnResultsGValuesFullScreen';
            app.btnResultsGValuesFullScreen.FontSize = 10.6666666666667;
            app.btnResultsGValuesFullScreen.Tooltip = 'Opens the residuals figure in new window.';
            app.btnResultsGValuesFullScreen.Position = [371 151 25.6 27.0769230769231];
            app.btnResultsGValuesFullScreen.Text = 'FS';

            % Create btnDZCResidualsFullScreen
            app.btnDZCResidualsFullScreen = uibutton(app.uipanel, 'push');
            app.btnDZCResidualsFullScreen.ButtonPushedFcn = createCallbackFcn(app, @btnDZCResidualsFullScreen_Callback, true);
            app.btnDZCResidualsFullScreen.Tag = 'btnDZCResidualsFullScreen';
            app.btnDZCResidualsFullScreen.FontSize = 10.6666666666667;
            app.btnDZCResidualsFullScreen.Tooltip = 'Opens the residuals figure in the new window.';
            app.btnDZCResidualsFullScreen.Position = [640 275 25.6 27.0769230769231];
            app.btnDZCResidualsFullScreen.Text = 'FS';

            % Create btnResultsResidualsFullScreen
            app.btnResultsResidualsFullScreen = uibutton(app.uipanel, 'push');
            app.btnResultsResidualsFullScreen.ButtonPushedFcn = createCallbackFcn(app, @btnResultsResidualsFullScreen_Callback, true);
            app.btnResultsResidualsFullScreen.Tag = 'btnResultsResidualsFullScreen';
            app.btnResultsResidualsFullScreen.FontSize = 10.6666666666667;
            app.btnResultsResidualsFullScreen.Tooltip = 'Opens the residuals figure in new window.';
            app.btnResultsResidualsFullScreen.Position = [935 275 25.6 27.0769230769231];
            app.btnResultsResidualsFullScreen.Text = 'FS';

            % Create btnDZCEnvelopeFullScreen
            app.btnDZCEnvelopeFullScreen = uibutton(app.uipanel, 'push');
            app.btnDZCEnvelopeFullScreen.ButtonPushedFcn = createCallbackFcn(app, @btnDZCEnvelopeFullScreen_Callback, true);
            app.btnDZCEnvelopeFullScreen.Tag = 'btnDZCEnvelopeFullScreen';
            app.btnDZCEnvelopeFullScreen.FontSize = 10.6666666666667;
            app.btnDZCEnvelopeFullScreen.Tooltip = 'Opens the envelope figure in the new window.';
            app.btnDZCEnvelopeFullScreen.Position = [638 151 25.6 27.0769230769231];
            app.btnDZCEnvelopeFullScreen.Text = 'FS';

            % Create btnLoadGravityData
            app.btnLoadGravityData = uibutton(app.uipanel, 'push');
            app.btnLoadGravityData.ButtonPushedFcn = createCallbackFcn(app, @btnLoadGravityData_Callback, true);
            app.btnLoadGravityData.Tag = 'btnLoadGravityData';
            app.btnLoadGravityData.FontSize = 10.6666666666667;
            app.btnLoadGravityData.Tooltip = 'Opens the figure in new window.';
            app.btnLoadGravityData.Position = [935 151 25.6 27.0769230769231];
            app.btnLoadGravityData.Text = 'FS';

            % Show the figure after all components are created
            app.figure1.Visible = 'on';
        end
    end

    % App creation and deletion
    methods (Access = public)

        % Construct app
        function app = GRGUI_App_exported(varargin)

            runningApp = getRunningApp(app);

            % Check for running singleton app
            if isempty(runningApp)

                % Create UIFigure and components
                createComponents(app)

                % Register the app with App Designer
                registerApp(app, app.figure1)

                % Execute the startup function
                runStartupFcn(app, @(app)GRGUI_OpeningFcn(app, varargin{:}))
            else

                % Focus the running singleton app
                figure(runningApp.figure1)

                app = runningApp;
            end

            if nargout == 0
                clear app
            end
        end

        % Code that executes before app deletion
        function delete(app)

            % Delete UIFigure when app is deleted
            delete(app.figure1)
        end
    end
end